from interfaces.welcome import WelcomeInterface
from interfaces.description import DescriptionInterface
from interfaces.game import GameInterface
from utils.config import SCREEN_WIDTH, SCREEN_HEIGHT, BG_IMAGE
from utils.window import get_window_position
from interfaces.leaderboard import LeaderboardInterface
from interfaces.game import GameInterface
import os
import pygame

def main():

    window_size = (GameInterface.BOARD_WIDTH * GameInterface.CELL_SIZE, GameInterface.BOARD_HEIGHT * GameInterface.CELL_SIZE)
    window_position = (100, 100)
    os.environ['SDL_VIDEO_WINDOW_POS'] = f"{window_position[0]},{window_position[1]}"
    while True:
        welcome_interface = WelcomeInterface(bg_image_filename=BG_IMAGE)
        choice = welcome_interface.show()
        window_position = get_window_position()
        if choice == 1:
            game_interface = GameInterface(bg_image_filename="playing_board.jpg", position=window_position, size=window_size)
            game_interface.start_game()
        elif choice == 2:
            os.environ['SDL_VIDEO_WINDOW_POS'] = f"{window_position[0]},{window_position[1]}"
            leaderboard_interface = LeaderboardInterface(
                bg_image_filename=BG_IMAGE,
                position=window_position,
                size=window_size
            )
            leaderboard_interface.show()
        elif choice == 5:
            break
        elif choice == 3:
            os.environ['SDL_VIDEO_WINDOW_POS'] = f"{window_position[0]},{window_position[1]}"
            description_interface = DescriptionInterface(
                bg_image_filename=BG_IMAGE,
                position=window_position,
                size=window_size
            )
            description_interface.show()
        elif choice == 4:
            break

if __name__ == "__main__":
    main()